package cn.itcast.service.impl;

import cn.itcast.domain.Catalog;
import cn.itcast.factory.MapperFactory;
import cn.itcast.mapper.CatalogMapper;
import cn.itcast.service.CatalogService;
import cn.itcast.utils.TransactionUtil;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CatalogServiceImpl implements CatalogService {
    //查询所有
    public List<Catalog> findAll(int pageNum) {
        //获取session
        SqlSession sqlSession = MapperFactory.getSqlSession();
        //获取mapper对象
        CatalogMapper mapper = sqlSession.getMapper(CatalogMapper.class);
        //分页
        PageHelper.startPage(pageNum,5);
        List<Catalog>  catalogList =  mapper.findAll();
        TransactionUtil.close(sqlSession);
        return catalogList;

    }
}
